package com.mmy.dao.group;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mmy.domain.group.TGroupProject;

/**
 * @vesion 
 * @description 
 * @author liys
 * @date 2021-5-24
 */
public interface TGroupProjectRepository extends JpaRepository<TGroupProject, Integer>{
	
	/**
	  * @descr 获取最大编号
	  * @param 
	  * @return 
	  * @throws 
	  * @author liys
	  * @date 2021-6-1
	 */
	@Query(value = "select MAX(iPlanID) from tGroupProject ", nativeQuery = true)
	Object getMaxID();
	
	/**
	  * @descr 创建只含id的对象
	  * @param 
	  * @return 
	  * @throws 
	  * @author liys
	  * @date 2021-6-1 
	 */
	@Transactional
	@Modifying
	@Query(value = "INSERT INTO tGroupProject(iPlanID, cCashierName, cCenterDetail, cChargeBack, cCreator, cCustomNum, cDriverTel, cGuideTel, cMemo, cReviser, cSpare3, cSpare4, cSpare5, cTicketSituation, dCashierDate, dCreateDate, dModifyDate, fActualTotal, fAddOil, fCharterCar, fMealAllowance, fReceive, fRoadBridge, fSpare2, fTotal, iCarID, iCashierID, iCashierState, iCreatorID, iGuideID, iKilometre, iReviserID, iSpare1, iTeamID, iTypeID) VALUES "
			+ "(:iPlanID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", nativeQuery = true)
	void insert(@Param("iPlanID")int iPlanID);
	
	/**
	  * @descr 本公司的已出团列表
	  * @param 
	  * @return 
	  * @throws 
	  * @author liys
	  * @date 2021-6-1
	 */
	@Query(value = "select * from tGroupProject where iSpare1 = :iOrgID", nativeQuery = true)
	List<TGroupProject> getGroups(@Param("iOrgID")int iOrgID);
	
	
}
